#include <my_header.h>
#include "threadPool.h"
/* Usage:  */
int tcpInit(int* sockfd,char* ip,char* port){
    *sockfd = socket(AF_INET,SOCK_STREAM,0);
    ERROR_CHECK(*sockfd,-1,"socket");
    int flag = 1;
    setsockopt(*sockfd,SOL_SOCKET,SO_REUSEADDR,&flag,sizeof(flag));
    struct sockaddr_in sockaddr;
    sockaddr.sin_family = AF_INET;
    sockaddr.sin_addr.s_addr = inet_addr(ip);
    sockaddr.sin_port = htons(atoi(port));

    int ret = bind(*sockfd,(struct sockaddr*)&sockaddr,sizeof(sockaddr));
    ERROR_CHECK(ret,-1,"bind");
    listen(*sockfd,10);

    return 0;
}

